<#include "/main.ftl"/>
<@diamondNav/>
<body>


<div id="content-wrapper" style="margin-left: 13%">
    <div style="margin-top: 5%;margin-left: 1%;width: 100%">


        <#if project.projectId??>
            <form action="/projectController/updateProject"
        <#else >
             <form action="/projectController/addProject"
        </#if>

                   method="post" id="myForm" class="form-horizontal" >
        <div class="form-group">
            <label class="col-md-2 control-label" for="projectName">项目名称</label>
            <div class="col-md-3">
                <input class="form-control" name="projectName" type="text" id="projectName"
                       placeholder="接口别名"
                       value="<#if project?? && project.projectName ??>${project.projectName!}</#if>"/>
                 <#if project??>
                     <@spring.bind "project.projectName" />
                     <span style="color: red"> <@spring.showErrors ""/> </span>
                 </#if>
            </div>
        </div>
        <div class="form-group">
            <div class="form-group">
                <label for="Header" class="control-label col-md-2">Header</label>
                <div id="headerDiv" class="col-md-10">
                        <#if project.headers?? && project.headers!=''>
                            <@writeKeyValue project.headers/>
                        <#else >
                            <input type="hidden" id="paramIndex" value="0">
                        </#if>
                </div>
            </div>
        </div>
        <div>
            <input type="hidden" name="headers" id="headers">
            <input type="hidden" name="hosts" id="hosts">
            <input name="projectId" type="hidden"
                   value="<#if project?? && project.projectId ??>${project.projectId!}</#if>">
        </div>
        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <button type="button" class="btn btn-success " id="back">
                    返回
                </button>
                <button type="button" class="btn btn-success " id="addHeader">
                    添加header
                </button>
                <button type="reset" class="btn btn-success ">
                    重置
                </button>
                <button type="submit" class="btn btn-success" onclick="oKeyValueUtil.writeParam()">
                    提交
                </button>
            </div>
        </div>
    </form>
    </div>
</div>
</body>

<script type="text/javascript">
    var oKeyValueUtil;
    $(function () {
        oKeyValueUtil = new KeyValueUtil();
        oKeyValueUtil.init($('#headerDiv'),$("#addHeader"), $("#headers"));
    });

    $("#back").click(function () {
        window.location.href = "/interfaceTestController/interfaceTestPage";
    })
</script>